<template>
  <Card>
    <div class="comments" v-if="comments&&comments.comments.length>0">
      <div class="item" v-for="item in comments.comments" :key="item.id">
        <div class="flex">
          <div class="left">
            <nuxt-link :to="{name:'topic-id',params:{id:item.targetId}}" v-text="item.title"></nuxt-link>
          </div>
          <div class="right">
            <span class="date" v-text="item.createTime"></span>
          </div>
        </div>
        <div class="content" v-html="item.content"></div>
      </div>
      <pagination :pages="comments.paginator.pages" :current="comments.paginator.current"
                  :route="{name:'profile-comments',params:{id:user.id}}"/>
    </div>
    <el-empty v-else description="没有数据"></el-empty>
  </Card>
</template>

<script>
export default {
  name: "ProfileComments",
  props: {
    user: Object,
    comments: Object
  }
}
</script>

<style scoped lang="less">

.comments {
  max-width:820px;
  overflow:auto;
  img{
    max-width:100%;
  }
  .item {
    .right {
      flex: 0 0 200px;
    }

    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);

    &:last-child {
      border-bottom: none;
      margin-bottom: 0;
      padding-bottom: 0;
    }

    .content {
      p {
        margin: 0 !important;
      }

      background: var(--bg);
      border-radius: 5px;
      margin: 5px;
      padding: 10px 5px;
    }
  }
}
</style>
